﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Oracle.DataAccess.Client;
using Oracle.DataAccess.Types;
using WAContratos;

namespace WebContratos
{
    public partial class htmlOutLook : System.Web.UI.Page
    {
        private string email = "";

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!(IsPostBack))
            {
                email = Convert.ToString(Request.QueryString["email"]);


                this.lblMessage.Attributes.Add("style", "display:none");

                string[] strArr = null;

                //char[] splitchar = { ' ' };
                try
                {
                    strArr = email.Split(';');

                    this.txtParaEmail.Text = strArr[0];
                    this.lblEmailDe.Text = strArr[1];
                }
                catch (Exception e1)
                {
                    this.lblEmailDe.Text = "";
                    this.txtParaEmail.Text = "";
                }
            }
        }

        protected void btnEnviar_Click(object sender, EventArgs e)
        {
            OracleConnection con = Conexion.Cone;
            try
            {

                OracleCommand Comm = new OracleCommand();
                Comm.Connection = con;

                this.txtParaEmail.Text = this.txtParaEmail.Text.Replace("%40", "@");

                if (this.lblEmailDe.Text.Equals(""))
                {
                    this.lblEmailDe.Text = "atipan@electricaguayaquil.gob.ec";
                }
                this.lblEmailDe.Text = this.lblEmailDe.Text.Replace("%40", "@");

                Comm.CommandText = "PKG_WEB.CLP_ENVIAEMAILANY";
                Comm.CommandType = CommandType.StoredProcedure; //.StoredProcedure();
                Comm.Parameters.Add("p_de", this.lblEmailDe.Text);//         '    VARCHAR2,
                Comm.Parameters.Add("p_para", this.txtParaEmail.Text); //.Direction = ParameterDirection.Output;//    ' OUT   cur,
                Comm.Parameters.Add("p_cc", ""); // Direction = ParameterDirection.Output;
                Comm.Parameters.Add("p_asunto", this.txtAsuntoEmail.Text); // Direction = ParameterDirection.Output;
                Comm.Parameters.Add("p_texto", this.ASPxHtmlEditor1.Html);        // 'in    varchar2 default null,
                Comm.Parameters.Add("p_resultado", OracleDbType.VarChar, 100).Direction = ParameterDirection.Output;
                //Comm.Parameters.Add("p_unidad", p_unidad);

                //OracleDataReader dtread;
                con.Open();
                int ou = Comm.ExecuteNonQuery(); //.ExecuteNonQuery(); //ExecuteReader();

                string resultado = Convert.ToString(Comm.Parameters["p_resultado"].Value);
                /*DataTable dtat = new DataTable();
                dtat.Load(dtread);
                dtat.TableName = "crcortes";
                dt.Tables.Add(dtat);*/

                con.Close();
                // return dt;
            }
            catch (Exception ex)
            {
                con.Close();
                // return dt;
            }
        }
    }
}
